Generating Gray Codes in O(1) Worst-Case Time per Word

نویسنده

  • Timothy Walsh
چکیده

We give a definition of Gray code that, unlike the standard “minimal change” definition, is satisfied by the word-lists in the literature called “Gray codes” and we give several examples to illustrate the various concepts of minimality. We show that a non-recursive generation algorithm can be obtained for a word-list such that all the words with the same prefix (or, equivalently, suffix) are consecutive and that the Bitner-Ehrlich-Reingold method of generating each word in a time bounded by a constant works under the additional condition that in the interval of words with the same prefix or suffix the next letter assumes at least two values. Finally we generalize this method so that it works under a weaker condition satisfied by almost all the Gray codes in the literature: if the next letter assumes only one value, then the interval contains only one word. 1 Definition of a Gray Code Gray codes have nothing to do with anything so sinister as the color gray, despite the fact that the first article on the subject [1] was published by the military. They were named after the author of that article, Frank Gray, who ordered the set of length-n binary strings (words on a two-letter alphabet, usually {0,1}, which represent subsets of {1, 2, ..., n}) into a list in which two consecutive strings differ in only one position (see Table 1 below), and probably also after the title: Pulse code communication. Subsequently, other sets of words that represent various combinatorial objects such as combinations or k -subsets (see Table 2 below), permutations (see Table 3 below), integer compositions, set partitions, integer partitions and binary trees (represented by Dyck words see Table 4 below) were ordered into lists in which two consecutive words differ in only a small number of positions, and these lists were called Gray codes because they share the same “minimal change” property as Gray’s pulse code. A Gray code is sometimes defined as a word-list in which the Hamming distance between any two adjacent words in the list (the number of positions in which these two words differ) is minimal. Most of the word-lists in the literature that are called Gray codes do not satisfy that definition or are published without a minimality proof. For example, if a k -subset of {1, 2, ..., n} is represented by its members in increasing order, then the Hamming distance between adjacent C.S. Calude et al. (Eds.): DMTCS 2003, LNCS 2731, pp. 73–88, 2003. c © Springer-Verlag Berlin Heidelberg 2003

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

In-Place Binary Counters

We introduce a binary counter that supports increments and decrements in O(1) worst-case time per operation. (We assume that arithmetic operations on an index variable that is stored in one computer word can be performed in O(1) time each.) To represent any integer in the range from 0 to 2−1, our counter uses an array of at most n bits plus few words of dlg(1 +n)e bits each. Extended-regular an...

متن کامل

Generating Binary Optimal Codes Using Heterogeneous Parallel Computing

Generation of optimal codes is a well known problem in coding theory. Many computational approaches exist in the literature for finding record breaking codes. However generating codes with long lengths n using serial algorithms is computationally very expensive, for example the worst case time complexity of a Greedy algorithm is O(n 4). In order to improve the efficiency of generating codes wit...

متن کامل

A Two-phase Practical Parallel Algorithm for Construction of Huffman Codes

The construction of optimal prefix codes plays a significant and influential role in applications concerning information processing and communication. For decades, different algorithms were proposed treating the issue of Huffman codes construction and various optimizations were introduced. In this paper we propose a detailed practical time-efficient parallel algorithm for generating Huffman cod...

متن کامل

Optimal Quasi-Gray Codes: Does the Alphabet Matter?

A quasi-Gray code of dimension n and length l over an alphabet Σ is a sequence of distinct words w1, w2, . . . , wl from Σ n such that any two consecutive words differ in at most c coordinates, for some fixed constant c > 0. In this paper we are interested in the read and write complexity of quasi-Gray codes in the bit-probe model, where we measure the number of symbols read and written in orde...

متن کامل

In-Place Length-Restricted Prefix Coding

Huuman codes, combined with word-based models, are considered eecient compression schemes for full-text retrieval systems. The decoding rate for these schemes can be substantially improved if the maximum length of the codewords is not greater then the machine word size L. However, if the vocabulary is large, simple methods for generating optimal length-restricted codes are either too slow or re...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2003